Skip to content

Migrate 5 API versions to shared arm_ml_service client#47554

Open
saanikaguptamicrosoft wants to merge 6 commits into
Azure:mainfrom
saanikaguptamicrosoft:saanika/tsp_migrate
Open

Migrate 5 API versions to shared arm_ml_service client#47554
saanikaguptamicrosoft wants to merge 6 commits into
Azure:mainfrom
saanikaguptamicrosoft:saanika/tsp_migrate

Conversation

@saanikaguptamicrosoft

Copy link
Copy Markdown
Contributor

Reuse the existing arm_ml_service generated client for the v2022_02_01_preview API surface instead of importing from the per-version restclient package, and delete azure/ai/ml/_restclient/v2022_02_01_preview/ (76 files).

  • _ml_client: wire the v2022_02_01_preview service client via a partial of MachineLearningServicesMgmtClient with api_version='2022-02-01-preview'.
  • Switch production imports (operations, entities, schema, utils) from azure.ai.ml._restclient.v2022_02_01_preview to azure.ai.ml._restclient.arm_ml_service and map the renamed hybrid models (JobBaseData -> JobBase, BatchDeploymentData -> BatchDeployment, OnlineEndpointData -> OnlineEndpoint, OnlineEndpointDetails -> OnlineEndpointProperties).
  • entities/_endpoint/online_endpoint.py: preserve the legacy 'endpoint' field on the wire via dict-style assignment since the new hybrid OnlineEndpointProperties model does not accept it as a constructor kwarg.
  • entities/_util.py: normalize_job_input_output_type now uses hard-coded camel-case keys ('Literal', 'UriFile', 'MlFlowModel', 'MlTable', ...) so it no longer depends on the v2022 generated JobInputType enum. The arm_ml_service JobInputType uses snake_case values and would silently break the v2022_02_01_preview payload normalization path that test_pipeline_component_entity / test_pipeline_job_entity exercise.
  • Update affected unit tests to import from arm_ml_service.
  • Delete the now-unused azure/ai/ml/_restclient/v2022_02_01_preview/ package.

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Reuse the existing arm_ml_service generated client for the v2022_02_01_preview
API surface instead of importing from the per-version restclient package, and
delete azure/ai/ml/_restclient/v2022_02_01_preview/ (76 files).

- _ml_client: wire the v2022_02_01_preview service client via a partial of
  MachineLearningServicesMgmtClient with api_version='2022-02-01-preview'.
- Switch production imports (operations, entities, schema, utils) from
  azure.ai.ml._restclient.v2022_02_01_preview to
  azure.ai.ml._restclient.arm_ml_service and map the renamed hybrid models
  (JobBaseData -> JobBase, BatchDeploymentData -> BatchDeployment,
  OnlineEndpointData -> OnlineEndpoint,
  OnlineEndpointDetails -> OnlineEndpointProperties).
- entities/_endpoint/online_endpoint.py: preserve the legacy 'endpoint' field
  on the wire via dict-style assignment since the new hybrid
  OnlineEndpointProperties model does not accept it as a constructor kwarg.
- entities/_util.py: normalize_job_input_output_type now uses hard-coded
  camel-case keys ('Literal', 'UriFile', 'MlFlowModel', 'MlTable', ...) so it
  no longer depends on the v2022 generated JobInputType enum. The
  arm_ml_service JobInputType uses snake_case values and would silently break
  the v2022_02_01_preview payload normalization path that
  test_pipeline_component_entity / test_pipeline_job_entity exercise.
- Update affected unit tests to import from arm_ml_service.
- Delete the now-unused azure/ai/ml/_restclient/v2022_02_01_preview/ package.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

The v2024_07_01_preview package had zero production consumers (datastore was consolidated onto 2024-10-01-preview earlier). The only remaining reference was an unused mock_aml_services_2024_07_01_preview conftest fixture; the equivalent mock_aml_services_2024_10_01_preview fixture already exists and points at the v2024_10_01_preview_tsp client. Delete the 76-file package and the stale fixture.
Reuse the existing arm_ml_service generated client for the v2025_01_01_preview
API surface instead of importing from the per-version restclient package, and
delete azure/ai/ml/_restclient/v2025_01_01_preview/.

- _ml_client: wire the v2025_01_01_preview service client via a partial of
  MachineLearningServicesMgmtClient with api_version='2025-01-01-preview'.
- Switch production imports (command builder/entity, job_resource_configuration,
  to_rest_functions, capability_host entity + operations) from
  azure.ai.ml._restclient.v2025_01_01_preview to
  azure.ai.ml._restclient.arm_ml_service.
- command_job.py: the shared CommandJob hybrid model does not declare
  parent_job_name, but it is a real field on the 2025-01-01-preview wire
  contract (wire key 'parentJobName'). Preserve it via dict-style assignment on
  the rest model rather than passing it as a constructor kwarg, and read it back
  via dict access in _load_from_rest.
- job_resource_configuration.py: same situation for max_instance_count
  (wire key 'maxInstanceCount', still declared on v2023_04_01_preview). Set it on
  the wire via dict assignment on the 202501 branch and read it back via
  obj.get('maxInstanceCount') for the hybrid model. Verified the value survives
  serialization and round-trip.
- Update conftest mock fixture and capability host entity test to import from
  arm_ml_service.
- test_command_job_schema: environment_variables is Dict[str, str] on the REST
  contract; the shared client coerces values to strings, so assert against the
  stringified expected values.
- Delete the now-unused azure/ai/ml/_restclient/v2025_01_01_preview/ package.
…n path

Verified against the frozen 2025-01-01-preview swagger (mfe.json on the
azure-ai-ml/before_tsp branch): maxInstanceCount does not exist anywhere in that
contract (0 occurrences; absent from JobResourceConfiguration and its base
ResourceConfiguration). The old v2025 autorest model silently ignored the
max_instance_count kwarg and never serialized it, so the wire-identical behavior
is to OMIT it on the arm_ml_service (202501) branch. The previous dict-style
assignment added an off-contract field and is reverted. The v2023_04 (else)
branch still sets max_instance_count because that version's swagger declares it.

parentJobName is unaffected and remains preserved via dict assignment in
command_job.py, since it IS a real 2025-01-01-preview field (declared on JobBase).
…ient

Consolidate the separate v2024_10_01_preview_tsp TypeSpec client onto the shared
arm_ml_service client (api_version='2024-10-01-preview') and delete the
v2024_10_01_preview_tsp package.

- _ml_client: wire the 2024-10 client as a partial of MachineLearningServicesMgmtClient
  with api_version='2024-10-01-preview' (kept the ServiceClient102024PreviewTsp alias name).
- Flip all 21 production imports + 7 test files from v2024_10_01_preview_tsp to arm_ml_service.
- THROWAWAY SHIM for two workspace properties that the shared client no longer declares:
  allowRoleAssignmentOnRG and networkAcls were @removed at api-version 2025-12-01 in the
  TypeSpec, and the shared client is generated at 2025-12-01, so its Workspace /
  WorkspaceUpdateParameters hybrid models reject them as kwargs. Both are still valid on the
  2024-10-01-preview wire (verified in workspaceRP.json). Added
  set_removed_workspace_property / get_removed_workspace_property helpers in
  _utils/_workspace_utils.py that round-trip these through the hybrid model's flattened
  'properties' envelope. networkAcls is nested and serialized via NetworkAcls.as_dict().
  Remove this shim once the shared client is regenerated with api-version 'all'.
- Update test_workspace_operations_base to assert the wire value
  (params.as_dict()['properties']['allowRoleAssignmentOnRG']) instead of the dropped attribute.
- Delete the now-unused azure/ai/ml/_restclient/v2024_10_01_preview_tsp/ package.
Move the workspace-connection auth models off the per-version v2022_01_01_preview
package onto the shared arm_ml_service client and delete the package.

- entities/_credentials.py: re-source the workspace-connection auth models from
  arm_ml_service with their current (renamed) names:
  PersonalAccessToken -> WorkspaceConnectionPersonalAccessToken,
  ServicePrincipal -> WorkspaceConnectionServicePrincipal,
  SharedAccessSignature -> WorkspaceConnectionSharedAccessSignature,
  UsernamePassword -> WorkspaceConnectionUsernamePassword,
  ManagedIdentity -> WorkspaceConnectionManagedIdentity.
- Cross-version coupling fix: the compute identity (IdentityConfiguration
  _to_compute_rest_object / _from_compute_rest_object, used by aml/compute_instance/
  kubernetes/synapsespark compute) is serialized through the msrest v2022_10
  ComputeResource. Source those two models from v2022_10_01_preview msrest instead
  of arm_ml_service so msrest serialization keeps working:
  Identity -> v2022_10_01_preview.ManagedServiceIdentity (same fields), and
  UserAssignedIdentity -> v2022_10_01_preview.UserAssignedIdentity. Without this the
  hybrid models raise SerializationError ('object has no attribute _attribute_map').
- Update conftest mock fixture and the connection unit test to import from
  arm_ml_service.
- Delete the now-unused azure/ai/ml/_restclient/v2022_01_01_preview/ package.
@saanikaguptamicrosoft saanikaguptamicrosoft changed the title Migrate v2022_02_01_preview consumers to shared arm_ml_service client Migrate 5 API versions to shared arm_ml_service client Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants